<?php
require_once("../../class2.php");
require_once(HEADERF);
$ratinguserpass=true;
require_once("./includes/require_all.php");
ramka("open");

IF($user_rights["APPROVE"]==1 AND isset($_GET['game'])) {
	IF (isset($_POST['rate'])) {
		FOREACH ($_POST['rate'] as $k=>$v) {
			mysql_query("UPDATE cms_usertests SET rate='$v',approuvedby='".USERNAME."' WHERE id='$k'");
		}
	}
	IF (isset($_GET['delete'])) {
		$k= mysql_real_escape_string($_GET['delete']);
		$flushed= mysql_fetch_assoc(mysql_query("SELECT * FROM cms_usertests WHERE id='$k'"));
		$tolog=""; FOREACH($flushed as $code=>$value) {
			$tolog.= $code.">>> ".$value."\n";
		} $tolog.="\n\n";
		file_put_contents("ratinguser-history.txt", $tolog, FILE_APPEND);
		mysql_query("DELETE FROM cms_usertests WHERE id='$k'");
	}
	$temp= mysql_query("SELECT * FROM cms_usertests WHERE game='$CMS_pref' AND rate='-1' ORDER BY date DESC");
	echo "<div class='forumheader3'><h1>Кандидатури ($gamename):</h1><div class='smalltext' style='padding:5px;'> Оценка 0 - за забрана на достъпа.<br>От 1 до 100 - по пренценка на оценяващия.<br>В бъдеще ще използвам оценките за разпределеня на допълнителни функции сред потребителите.</div></div>";
	WHILE ($userer= mysql_fetch_assoc($temp)) {
		$ENs= explode("<:|:>",$userer["english"]);
		$BGs= explode("<:|:>",$userer["bulgarian"]);
		$toprint= "";
		FOREACH ($ENs as $k=>$EN) {
			$EN= str_replace("<","&lt;",$EN);
			$BG= str_replace("<","&lt;",$BGs[$k]);
			$toprint.= "<div class='forumheader3'><div class='textGREY'>$EN</div><div class='textWHITE'>$BG</div></div>";
		}
		?>
		<style>
			.delbut {
				opacity: 0.5;
			}.delbut:hover {
				opacity: 1;
			}
		</style>
		<div class="forumheader3">
			<div class="forumheader">
				<span class="textWHITE"><?=$userer['username']?></span>
				<span style="padding-left:10px;"></span>
				<a href="ratinguser-app.php?game=<?=$_GET['game']?>&delete=<?=$userer['id']?>" class="textReD delbut">Изтрий</a>
				<span style="float:right"><?=$userer['date']?></span>
			</div>
			<form method="post" action="<?=$PHP_SELF?>" class="forumheader3">
				<?=$toprint?>
				<div class="forumheader3">
					<div class='textWHITE'><?=$userer['comment']?></div>
				</div>
				<center class="forumheader">
					<input name="rate[<?=$userer['id']?>]" type="number" value="0" min="0" max="100" class="tbox"/>
					<input type="submit" value="Запамети" class="button"/>
				</center>	
			</form>
		</div>
		<div class='forumheader4' style='min-height:5px;'></div>
		<?php
	}
}

ramka("close");
require_once(FOOTERF);
?>